package fun._6742.model.dataobject;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import fun._6742.model.valueobject.CartVO;
import lombok.*;

import java.math.BigDecimal;

@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
@TableName("cart")
public class CartDO {
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    private Long userId;
    private Integer totalNum = 0;
    private BigDecimal totalPrice = BigDecimal.valueOf(0);
    private BigDecimal realPayPrice = BigDecimal.valueOf(0);

    public void update(CartVO cartVO) {
        this.totalNum = cartVO.getTotalNum();
        this.totalPrice = cartVO.getTotalPrice();
        this.realPayPrice = cartVO.getRealPayPrice();
    }
}
